package org.dreamfly.core.remote.register;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.dreamfly.core.remote.ServiceModel;
import org.dreamfly.core.remote.ServiceRepository;

/**
 * Created by IntelliJ IDEA.
 * User: Gin
 * Date: 2010-11-27
 * Time: 2:22:27
 * To change this template use File | Settings | File Templates.
 */
public class ServiceRegisterSupport implements ServiceRegister{

    /** Logger */
    private static final Logger logger = LogManager.getLogger(ServiceRegisterSupport.class);

    /** 服务中心 */
    private ServiceRepository serviceRepository;

    /*
     * @see com.alipay.common.service.repository.ServiceRegister#registService(com.alipay.common.service.repository.ServiceModel)
     */
    public boolean registService(ServiceModel serviceModel) {
        try {
            serviceRepository.registService(serviceModel);
        } catch (Exception e) {
            logger.error("注册服务失败，失败原因：" ,e);
            return false;
        }
        return true;
    }

    //容器注入

    /**
     * @param serviceRepository the serviceRepository to set
     */
    public void setServiceRepository(ServiceRepository serviceRepository) {
        this.serviceRepository = serviceRepository;
    }
}
